{
  "cells": [
    {
      "cell_type": "markdown",
      "id": "f851cef5",
      "metadata": {},
      "source": [
        "# DoglegOptimizer\n",
        "\n",
        "## Overview\n",
        "\n",
        "The `DoglegOptimizer` class in GTSAM is a specialized optimization algorithm designed for solving nonlinear least squares problems. It implements the Dogleg method, which is a hybrid approach combining the steepest descent and Gauss-Newton methods.\n",
        "\n",
        "The Dogleg method is characterized by its use of two distinct steps:\n",
        "\n",
        "1. **Cauchy Point**: The steepest descent direction, calculated as:\n",
        "   $$ p_u = -\\alpha \\nabla f(x) $$\n",
        "   where $\\alpha$ is a scalar step size.\n",
        "\n",
        "2. **Gauss-Newton Step**: The solution to the linearized problem, providing a more accurate but computationally expensive step:\n",
        "   $$ p_{gn} = -(J^T J)^{-1} J^T r $$\n",
        "   where $J$ is the Jacobian matrix and $r$ is the residual vector.\n",
        "\n",
        "The Dogleg step, $p_{dl}$, is a combination of these two steps, determined by the trust region radius $\\Delta$.\n",
        "\n",
        "Key features:\n",
        "\n",
        "- **Hybrid Approach**: Combines the strengths of both the steepest descent and Gauss-Newton methods.\n",
        "- **Trust Region Method**: Utilizes a trust region to determine the step size, balancing between the accuracy of Gauss-Newton and the robustness of steepest descent.\n",
        "- **Efficient for Nonlinear Problems**: Designed to handle complex nonlinear least squares problems effectively."
      ]
    },
    {
      "cell_type": "markdown",
      "id": "colab_button",
      "metadata": {},
      "source": [
        "<a href=\"https://colab.research.google.com/github/borglab/gtsam/blob/develop/gtsam/nonlinear/doc/DoglegOptimizer.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
      ]
    },
    {
      "cell_type": "markdown",
      "id": "license_cell",
      "metadata": {
        "tags": [
          "remove-cell"
        ]
      },
      "source": [
        "GTSAM Copyright 2010-2022, Georgia Tech Research Corporation,\nAtlanta, Georgia 30332-0415\nAll Rights Reserved\n\nAuthors: Frank Dellaert, et al. (see THANKS for the full author list)\n\nSee LICENSE for the license information"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "id": "colab_import",
      "metadata": {
        "tags": [
          "remove-cell"
        ]
      },
      "outputs": [],
      "source": [
        "try:\n    import google.colab\n    %pip install --quiet gtsam-develop\nexcept ImportError:\n    pass"
      ]
    },
    {
      "cell_type": "markdown",
      "id": "758e347b",
      "metadata": {},
      "source": [
        "## Key Methods\n",
        "\n",
        "Please see the base class [NonlinearOptimizer.ipynb](NonlinearOptimizer.ipynb).\n",
        "\n",
        "## Parameters\n",
        "\n",
        "The `DoglegParams` class defines parameters specific to Powell's Dogleg optimization algorithm:\n",
        "\n",
        "| Parameter | Description |\n",
        "|-----------|-------------|\n",
        "| `deltaInitial` | Initial trust region radius that controls step size (default: 1.0) |\n",
        "| `verbosityDL` | Controls algorithm-specific diagnostic output (options: SILENT, VERBOSE) |\n",
        "\n",
        "These parameters complement the standard optimization parameters inherited from `NonlinearOptimizerParams`, which include:\n",
        "\n",
        "- Maximum iterations\n",
        "- Relative and absolute error thresholds\n",
        "- Error function verbosity\n",
        "- Linear solver type\n",
        "\n",
        "Powell's Dogleg algorithm combines Gauss-Newton and gradient descent approaches within a trust region framework. The `deltaInitial` parameter defines the initial size of this trust region, which adaptively changes during optimization based on how well the linear approximation matches the nonlinear function.\n",
        "\n",
        "## Usage Considerations\n",
        "\n",
        "- **Initial Guess**: The performance of the Dogleg optimizer can be sensitive to the initial guess. A good initial estimate can significantly speed up convergence.\n",
        "- **Parameter Tuning**: The choice of the initial trust region radius and other parameters can affect the convergence rate and stability of the optimization.\n",
        "\n",
        "## Files\n",
        "\n",
        "- [DoglegOptimizer.h](https://github.com/borglab/gtsam/blob/develop/gtsam/nonlinear/DoglegOptimizer.h)\n",
        "- [DoglegOptimizer.cpp](https://github.com/borglab/gtsam/blob/develop/gtsam/nonlinear/DoglegOptimizer.cpp)\n",
        "- [DoglegParams.h](https://github.com/borglab/gtsam/blob/develop/gtsam/nonlinear/DoglegParams.h)"
      ]
    }
  ],
  "metadata": {
    "language_info": {
      "name": "python"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 5
}